
from Common import *
import mjin2

class GamePlayer(object):
    def __init__(self, application):
        self.actionController = None
        self.application = application
        self.data = {}
        self.sceneCamera = None
        self.sceneCameraController = None
        self.scenePlayer = None
        self.scenePlayerController = None
    def setActionController(self, ac):
        if (self.actionController):
            self.application.wnd.removeInputListener(self.actionController)
            self.actionController.setCamera(None)
            self.actionController.setPlayer(None)
        self.actionController = ac
        if (ac):
            ac.setCamera(self.application.wnd.camera())
            ac.setPlayer(self)
            self.application.wnd.addInputListener(ac)
    def setScene(self, scene):
        self.application.wnd.setScene(scene)
    def setSceneCamera(self, camera):
        if (self.sceneCamera):
            self.sceneCamera.setCamera(None)
        self.sceneCamera = camera
        if (self.sceneCamera):
            self.sceneCamera.setCamera(self.application.wnd.camera())
    def setSceneCameraController(self, controller):
        if (self.sceneCameraController):
            self.application.wnd.removeInputListener(self.sceneCameraController)
            self.sceneCameraController.setCamera(None)
            self.sceneCameraController.setPlayer(None)
        self.sceneCameraController = controller
        if (self.sceneCameraController):
            self.sceneCameraController.setCamera(self.sceneCamera)
            self.sceneCameraController.setPlayer(self)
            self.application.wnd.addInputListener(self.sceneCameraController)
    def setScenePlayer(self, player):
        self.scenePlayer = player
    def setScenePlayerController(self, controller):
        if (self.scenePlayerController):
            self.application.wnd.removeInputListener(self.scenePlayerController)
            self.scenePlayerController.setPlayer(None)
        self.scenePlayerController = controller
        if (self.scenePlayerController):
            self.scenePlayerController.setPlayer(self)
            self.application.wnd.addInputListener(self.scenePlayerController)

